@extends('admin.common.main')
@section('header')
    {{--  <link rel="stylesheet" href="/admin/js/bootstrap.min.css">--}}
    <link rel="stylesheet" href="/admin/js/pagination.css">

@endsection

@section('content')
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 接口账号管理 <span class="c-gray en">&gt;</span> 用户管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="page-container">
        <div class="text-c">

            <form action="{{route('admin.apiuser.index')}}">
                节点：
                <input type="text" class="input-text" value="" style="width:250px" placeholder="输入管理员名称" id="" name="name">
                <button type="submit" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜名称</button>
            </form>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>

                <a href="{{route('admin.apiuser.create')}}"  class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加账号</a></span> <span class="r">共有数据：<strong>88</strong> 条</span> </div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-hover table-bg table-sort">
                <thead>
                <tr class="text-c">
                    <th width="25"><input type="checkbox" class="checkAll" value=""></th>
                    <th width="100">id</th>
                    <th width="130">账号</th>
                    <th width="100">密码</th>

                    <th width="70">次数</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($data as $key=>$val)
                    <tr class="text-c">
                        <th width="25"><input type="checkbox" name="ids[]" value="{{$val['id']}}"></th>
                        <th width="100">{{$val['id']}}</th>
                        <td >{{$val['html']}}{{$val['username']}}</td>
                        <td style="text-align: left">{{$val['password']}}</td>

                        <td class="td-status">{{$val['click']}}</td>
                        <td class="td-manage">
                            <a href="{{route('admin.apiuser.edit',$val)}}"  class="label label-default radius ">修改</a>

                            <a href="{{route('admin.apiuser.destroy',$val)}}"  class="label label-danger radius delBtn">删除</a>
                        </td>
                    </tr>

                @endforeach
                </tbody>
            </table>


        </div>
        {{--分页并保留 搜索条件--}}
        {{-- {{$data->appends(Request::all())->links()}}--}}



    </div>

@endsection


@section('js')
    <script type="text/javascript">


        $('.checkAll').click(function () {
            $("input[name='ids[]']").prop("checked",$(this).prop("checked"))
        })

        /*用户-删除*/
        $('.delBtn').click(function () {

            let url= $(this).attr('href');


            let _that=$(this);
            layer.confirm('确认要删除吗？',function(index){
                $.ajax({
                    type: 'DELETE',
                    data:{ _token:"{{csrf_token()}}" },
                    url:url,
                    dataType: 'json',
                    success: data =>{
                        if(data.error_code ==0 ){

                            _that.parents("tr").remove();
                            layer.msg(data.msg,{icon:1,time:1000});
                        }else{

                            layer.msg(data.msg,{icon:1,time:1000});
                        }
                    }
                });
            });


            return false
        });



        /*用户-恢复*/
        $('.resBtn').click(function () {

            let url= $(this).attr('href');


            let _that=$(this);

            $.ajax({
                type: 'get',
                url:url,
                dataType: 'json',
                success: data =>{

                    layer.msg(data.msg,{icon:1,time:1000});
                }
            });



            return false
        });


    </script>

@endsection

